package 优先算法.递归_搜索与回溯.综合案列.组合;

import java.util.ArrayList;
import java.util.List;

public class Main {
}
class Solution {
    List<Integer> path;
    List<List<Integer>> ret;
    int n,k;
    public List<List<Integer>> combine(int _n, int _k) {
        n=_n;k=_k;
        path = new ArrayList<>();
        ret = new ArrayList<>();

        dfs(1);
        return ret;
    }
    public void dfs(int start){
        if(path.size() == k){
            ret.add(new ArrayList<>(path));
            return;
        }
        for(int i = start;i<=n;i++){
            path.add(i);
            dfs(i+1);

            //恢复现场
            path.remove(path.size()-1);
        }
    }
}
